﻿

//声明了个控制权名称：common.views.disputeInformations.index
(function () {
    appModule.controller('common.views.disputeInformationHandles.pie', [
      '$scope', '$uibModal', '$stateParams', 'uiGridConstants', 'abp.services.app.disputeInformation', 'abp.services.app.area', "$state",
        function ($scope, $uibModal, $stateParams, uiGridConstants, disputeInformationService, areaService, $state) {
            var vm = this;

            $scope.$on('$viewContentLoaded', function () {
                //这里应该是当页面加载完毕后，进行信息的初始化
                //实际会去调用 icheck、select2等js的初始化插件。来渲染页面
                App.initAjax();
            });
            //告知页面信息已经下载完毕
            vm.loading = false;

            //返回
            vm.back = function () {
                //跳转页面
                $state.go('fenXiYanPan');
            };

            vm.loadControl = function () {
                vm.loading = true;
                disputeInformationService.getPie()
                    .then(function (result) {

                        var data = result.data.items;
                        var jsonStr = "";
                        jsonStr += "[";
                        for (var i = 0; i < data.length; i++) {
                            jsonStr += "['" + data[i].x + "', " + data[i].y + "],";
                        }
                        jsonStr = jsonStr.substring(0, (jsonStr.length - 1));
                        jsonStr += "]";

                        var json = eval(jsonStr);

                        $('#graph').highcharts({
                            chart: {
                                plotBackgroundColor: null,
                                plotBorderWidth: null,
                                plotShadow: false
                            },
                            title: {
                                text: '饼状图纠纷量占比'
                            },
                            tooltip: {
                                headerFormat: '{series.name}<br>',
                                pointFormat: '{point.name}: <b>{point.percentage:.1f}%</b>'
                            },
                            plotOptions: {
                                pie: {
                                    allowPointSelect: true,
                                    cursor: 'pointer',
                                    dataLabels: {
                                        enabled: true,
                                        format: '<b>{point.name}</b>: {point.percentage:.1f} %',
                                        style: {
                                            color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
                                        }
                                    }
                                }
                            },
                            series: [{
                                type: 'pie',
                                name: '纠纷量占比',
                                data: json
                            }]
                        });

                    }).finally(function () {
                        vm.loading = false;
                    });
            };

            vm.loadControl();

        }
    ]);
})();









